package com.fowo.api.controller.handleWork;

import com.fowo.api.common.model.IdListPo;
import com.fowo.api.common.model.R;
import com.fowo.api.model.scan.shipment.InspectGoodsVo;
import com.fowo.api.model.scan.shipment.ScanShipmentVo;
import com.fowo.api.service.handleWork.ScanShipmentAddService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "扫码发货")
@RequestMapping("/api/scan-shipment")
@RestController
public class ScanShipmentAddController {
    @Resource
    private ScanShipmentAddService scanShipmentAddService;

    @Operation(summary = "根据系统单号、运单号或跟踪号获取详情")
    @GetMapping("/order-id/info")
    public R<ScanShipmentVo> getVoByOrderId(@RequestParam String orderId,@RequestParam List<Long> deliveryLogisticsChannelInList){
        return R.data(() -> scanShipmentAddService.getVoByOrderId(orderId,deliveryLogisticsChannelInList));
    }

    @Operation(summary = "验货")
    @PostMapping("/order-id/inspect")
    public R inspectGoods(@RequestBody InspectGoodsVo model){
        return R.run(() -> scanShipmentAddService.inspectGoods(model));
    }

    @Operation(summary = "称重")
    @PostMapping("/order-id/weigh")
    public R weight(@RequestBody InspectGoodsVo model){
        return R.run(() -> scanShipmentAddService.weight(model));
    }
    @Operation(summary = "发货")
    @PostMapping("/order-id/shipments")
    public R shipments(@RequestBody IdListPo po){
        return R.run(() -> scanShipmentAddService.shipments(po.getIds()));
    }
}
